
import 'package:flutter_eve_plugin/store/base_action.dart';
import 'package:flutter_eve_plugin/store/ye_xiu/rank/main.dart';
import 'package:redux/redux.dart';

import 'constant.dart';

RankState rankReducer(RankState state, action) {
  if (!(action is BaseAction)) {
    return state;
  }
  BaseAction baseAction = action;
  var data = baseAction.data;
  switch (baseAction.type) {
    case RANKING_COIN:
      return state.copyWith(coinData:BaseRankState(rankUserList:data.data.topUsers,selfRank: data.data.self));
      break;
    case RANKING_WEAPON:
      return state.copyWith(weaponData:BaseRankState(rankUserList:data.data.topUsers,selfRank: data.data.self));
      break;
    case RANKING_ROLE:
      return state.copyWith(roleData:BaseRankState(rankUserList:data.data.topUsers,selfRank: data.data.self));
      break;
    case RANKING_ABILITY:
      return state.copyWith(abilityData:BaseRankState(rankUserList:data.data.topUsers,selfRank: data.data.self));
      break;
  }
  return state;
}

// ignore: non_constant_identifier_names
final RankReducer = combineReducers<RankState>([rankReducer]);
